#########################
#                       #
#    LODModS Patcher    #
#   ~~~version 1.31~~~  #
#  by theflyingzamboni  #
#                       #
#########################

----------------
What is LODModS?
----------------
The Legend of Dragoon Modding System (LODModS) is my attempt to make a single unified system for creating and applying mods to LOD. Currently, mods for the game tend to be installed in similar, but slightly different ways using batch files and separately downloaded dependencies. Further, there has been no coordinated attempt to maximize compatibility between mods by different modders. Finally, mods come in a couple different varieties: patches for game files, and scripts to swap game files from one version to another. 

All this means that each mod has to be installed separately, and in some cases, in a specific order not clear to the user. Even with just the few mods available, this process can get complicated, and has the potential to cause increasing problems going into the future as the number of mods (hopefully) grows.

LODModS attempts to solve these problems in a few ways:
1. Making it possible to install all desired mods by running a single program that already comes bundled with the necessary open-source dependencies, and requires minimal user input.
2. Targeting the smallest file units possible within the game's data structure for patches and file swaps.
3. Using file lists to direct file extraction/insertion and patching/swapping, and to check for potential compatibility issues.
4. Disable checksum verification to allow for patch stacking.

-----
Setup
-----
IMPORTANT: Patcher will create clean backups of the discs with a .orig extension. DO NOT delete these files.

Also IMPORTANT, but not quite as much: Only do step 2 once ALL desired mods have been set up, so the patcher doesn't have to be run multiple times.

1. Save all mod downloads to the "mods" folder. Make sure to unzip the folders after downloading them, so that the patcher can detect the mod files.
2. Run the patcher and follow the instructions as they appear. Setting the game disc directories and file names will only need be completed the first time the patcher is run. 
	- If you are unsure what your game directories are, right click on one of the discs and select properties. The correct path will be next to "Location" (if you are using Windows).
	- Make sure that the discs detected are correct. If they are not, enter 'n' or 'no' and enter the file name (with iso, bin, or img extension) manually for each disc as prompted.
	- The Japanese directory is optional, and only required when installing a mod that requires it. To skip, just press Enter.

-------
Details
-------
NOTE: Knowing these details is not necessary for installing mods, as the patcher updates them for the user.

The LODModS patcher relies on two text files to direct its file operations: patcher.config and file_list.txt. As detailed in Setup, users will only need to concern themselves with some parts of patcher.config, and won't need to do anything with file_list.txt. Each mod will come with their own patcher.config and file_list.txt files, which the patcher will use to update its own copies of the files with mod-specific information each time it is run.

~~patcher.config~~
	- [Game Directories] - Folders where each version's game disc images (ISO, BIN or IMG) are located
	- [Modding Directories] - Folders generated for various modding purposes. Their values can be changed to point to different folders if the user chooses, but this is not necessary.
		- Game Files - Folder that the disc images' files will be extracted to.
	- [File Lists] - File name of the file list text file that directs extraction/insertion of subfiles and assets, decompression/compression, patching, and file swapping for files extracted from the discs of the specified version. Uses file_list.txt by default.
	- [File Swap] - Specifies the game versions and directions of file swaps to be made using the format "source:destination". By default, the standalone patcher only does swaps from the Japanese to US version, and uses file_list.txt to specify which files to swap.
	- [Mod List] - List of directories for mods to install. Mods set to 1 will be installed, mods set to 0 will not.
	- [Game Discs] - Specifies file names for discs for each version of the game, as well as which files should be extracted from them. Files set to 1 will be extracted, files set to 0 will not.

~~file_list.txt~~
	- [PATCH] - Specifies files that xdelta patches will be applied to, as well as the parent files they are extracted from.
	- [SWAP] - Specifies files that will be copied from a different version of the game, as well as the parent files they are extracted from.

---------
Changelog
---------
Version 1.31 (02-15-2019)
	- Disc checking now filters for words 'lod' or 'dragoon' to filter out other games
	- Patcher checks for altered patches before closing to restore them from backup, fixing a bug where an exception in the patching process could break BPE patches
Version 1.3 (02-14-2019)
	- Changed user interface to simplify instructions and remove need for user to directly edit patcher.config.
Version 1.2 (02-13-2019)
	- Altered how patches are applied slightly to allow patch stacking on files
Version 1.12 (02-04-2019)
	- Fixed bug that would cause patcher to crash if the Japanese disc name were not filled in, regardless of whether they were needed
	- Small fix to make config file and file list tolerant of extraneous whitespace
Version 1.11 (02-02-2019)
	- Fixed issue that would have prevented alternate versions of the same xdelta file from copying to the patches folder if another version had already been used
Version 1.1 (01-29-2019)
	- Initial public release
	
-------
Credits
-------
This patcher relies on several additional utilities in addition to its own to handle certain file operations, and full credit goes to the creators of those programs.

- CDPatch (Neill Corlett - http://www.romhacking.net/utilities/1440/) - Used to remove files from disc images, as well as inserting .XA and .IKI files.
- PSX-Mode2 (CUE - http://www.romhacking.net/utilities/848/, ENG version - http://www.romhacking.net/utilities/1417/) - Used to insert disc files that do not have the .XA or .IKI extensions.
- Xdelta3 (Josh MacDonald - http://xdelta.org/) - Used to create and apply xdelta patches.


--------------
Special Thanks
--------------
Big thanks to The Legend of Dragoon Discord users SarumSword, DrewUniverse, and Zychronix, who helped test and offer feedback on various versions of this patcher.

----------
Last Notes
----------
If you run into any issues using the LODModS patcher, I can be reached most easily in the #modding-tools channel on the LOD Discord server (https://discord.gg/rQWXgK5 ). Less preferably, I can also be reached by message on Reddit at u/theflyingzamboni, or by post on my personal project page on romhacking.net (http://www.romhacking.net/forum/index.php?topic=25929.0).